<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>geolite2-redist - v3.0.3</title><meta name="description" content="Documentation for geolite2-redist - v3.0.3"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script async src="assets/search.js" id="search-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os"</script><header class="tsd-page-toolbar">
<div class="tsd-toolbar-contents container">
<div class="table-cell" id="tsd-search" data-base=".">
<div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><path d="M15.7824 13.833L12.6666 10.7177C12.5259 10.5771 12.3353 10.499 12.1353 10.499H11.6259C12.4884 9.39596 13.001 8.00859 13.001 6.49937C13.001 2.90909 10.0914 0 6.50048 0C2.90959 0 0 2.90909 0 6.49937C0 10.0896 2.90959 12.9987 6.50048 12.9987C8.00996 12.9987 9.39756 12.4863 10.5008 11.6239V12.1332C10.5008 12.3332 10.5789 12.5238 10.7195 12.6644L13.8354 15.7797C14.1292 16.0734 14.6042 16.0734 14.8948 15.7797L15.7793 14.8954C16.0731 14.6017 16.0731 14.1267 15.7824 13.833ZM6.50048 10.499C4.29094 10.499 2.50018 8.71165 2.50018 6.49937C2.50018 4.29021 4.28781 2.49976 6.50048 2.49976C8.71001 2.49976 10.5008 4.28708 10.5008 6.49937C10.5008 8.70852 8.71314 10.499 6.50048 10.499Z" fill="var(--color-text)"></path></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div>
<ul class="results">
<li class="state loading">Preparing search index...</li>
<li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">geolite2-redist - v3.0.3</a></div>
<div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><rect x="1" y="3" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="7" width="14" height="2" fill="var(--color-text)"></rect><rect x="1" y="11" width="14" height="2" fill="var(--color-text)"></rect></svg></a></div></div></header>
<div class="container container-main">
<div class="col-8 col-content">
<div class="tsd-page-title">
<h2>geolite2-redist - v3.0.3</h2></div>
<div class="tsd-panel tsd-typography">
<a href="#node-geolite2-redist" id="node-geolite2-redist" style="color: inherit; text-decoration: none;">
  <h1>node-geolite2-redist</h1>
</a>
<p><a href="https://github.com/GitSquared/node-geolite2-redist/actions?query=workflow%3A%22Databases+Updater%22"><img src="https://github.com/GitSquared/node-geolite2-redist/workflows/Databases%20Updater/badge.svg?branch=master&event=schedule" alt="Automatic Redistribution Updates"></a> <a href="https://www.npmjs.com/package/geolite2-redist"><img src="https://badgen.net/npm/v/geolite2-redist" alt="NPM published version"></a> <a href="https://nodejs.org/en/about/releases/"><img src="https://badgen.net/npm/node/geolite2-redist" alt="Node version"></a> <a href="#typescript"><img src="https://badgen.net/npm/types/geolite2-redist" alt="Types Status"></a></p>
<hr>
<p>MaxMind&#39;s GeoLite2 free databases as an npm library. <strong>As this is a redistribution, you don&#39;t need a MaxMind license key.</strong> However, some additional legal restrictions apply, make sure to read this README and the <a href="#legal-warning">Legal Warning</a> carefully before deciding to use this.</p>
<p>You will need a database reader capable of reading <code>.mmdb</code> files, like <a href="https://www.npmjs.com/package/maxmind">node-maxmind</a>, if you wish to use the data.</p>
<p>This package is compatible with the 3 GeoLite2 databases, namely:</p>
<ul>
<li><code>GeoLite2-ASN</code></li>
<li><code>GeoLite2-Country</code></li>
<li><code>GeoLite2-City</code></li>
</ul>
<p>For more info check out the <a href="https://dev.maxmind.com/geoip/geolite2-free-geolocation-data">MaxMind website</a>.</p>
<p>Due to license requirements, <strong>this package automatically updates the databases in the background</strong> when it detects that a new version is available. This should be transparent for most usecases, if you&#39;re experiencing any problem with it, please file an issue.</p>
<p>See <a href="#legal-warning">Legal Warning</a> section for more info on licensing and limitations.</p>

<a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
  <h2>Usage</h2>
</a>

<a href="#installing" id="installing" style="color: inherit; text-decoration: none;">
  <h3>Installing</h3>
</a>
<p><code>npm install geolite2-redist</code></p>

<a href="#using-the-geoip-data" id="using-the-geoip-data" style="color: inherit; text-decoration: none;">
  <h3>Using the geoip data</h3>
</a>
<p>Example geoip lookup in a Node environment, using the <code>GeoLite2-City</code> database with <code>node-maxmind</code> as a db reader:</p>

<a href="#javascript" id="javascript" style="color: inherit; text-decoration: none;">
  <h4>Javascript</h4>
</a>
<pre><code class="language-javascript"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">maxmind</span><span class="hl-1"> = </span><span class="hl-3">require</span><span class="hl-1">(</span><span class="hl-4">&#39;maxmind&#39;</span><span class="hl-1">);</span><br/><br/><span class="hl-5">// This module is distributed as en ESM module (import...from... syntax), but you can</span><br/><span class="hl-5">// use an import() promise to make it work without switching to ESM!</span><br/><span class="hl-0">import</span><span class="hl-1">(</span><span class="hl-4">&#39;geolite2-redist&#39;</span><span class="hl-1">).</span><span class="hl-3">then</span><span class="hl-1">((</span><span class="hl-6">geolite2</span><span class="hl-1">) </span><span class="hl-0">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-7">return</span><span class="hl-1"> </span><span class="hl-6">geolite2</span><span class="hl-1">.</span><span class="hl-3">open</span><span class="hl-1">(</span><br/><span class="hl-1">  </span><span class="hl-4">&#39;GeoLite2-City&#39;</span><span class="hl-1">,                 </span><span class="hl-5">// database name</span><br/><span class="hl-1">  (</span><span class="hl-6">dbPath</span><span class="hl-1">) </span><span class="hl-0">=&gt;</span><span class="hl-1"> </span><span class="hl-6">maxmind</span><span class="hl-1">.</span><span class="hl-3">open</span><span class="hl-1">(</span><span class="hl-6">dbPath</span><span class="hl-1">) </span><span class="hl-5">// function that builds a useful db reader</span><br/><span class="hl-1">  )</span><br/><span class="hl-1">}).</span><span class="hl-3">then</span><span class="hl-1">((</span><span class="hl-6">reader</span><span class="hl-1">) </span><span class="hl-0">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1">  </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">lookup</span><span class="hl-1"> = </span><span class="hl-6">reader</span><span class="hl-1">.</span><span class="hl-3">get</span><span class="hl-1">(</span><span class="hl-4">&#39;185.194.81.29&#39;</span><span class="hl-1">)</span><br/><br/><span class="hl-1">  </span><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-3">log</span><span class="hl-1">(</span><span class="hl-6">lookup</span><span class="hl-1">.</span><span class="hl-6">country</span><span class="hl-1">.</span><span class="hl-6">iso_code</span><span class="hl-1">) </span><span class="hl-5">// FR 🥖🇫🇷</span><br/><br/><span class="hl-1">  </span><span class="hl-5">// Calling close() here shuts everything down nicely and clears up Node&#39;s event loop.</span><br/><span class="hl-1">  </span><span class="hl-6">reader</span><span class="hl-1">.</span><span class="hl-3">close</span><span class="hl-1">()</span><br/><span class="hl-1">})</span>
</code></pre>

<a href="#typescript" id="typescript" style="color: inherit; text-decoration: none;">
  <h4>Typescript</h4>
</a>
<pre><code class="language-typescript"><span class="hl-7">import</span><span class="hl-1"> </span><span class="hl-6">geolite2</span><span class="hl-1">, { </span><span class="hl-6">GeoIpDbName</span><span class="hl-1"> } </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-4">&#39;geolite2-redist&#39;</span><span class="hl-1">;</span><br/><span class="hl-7">import</span><span class="hl-1"> </span><span class="hl-6">maxmind</span><span class="hl-1">, { </span><span class="hl-6">CountryResponse</span><span class="hl-1"> } </span><span class="hl-7">from</span><span class="hl-1"> </span><span class="hl-4">&#39;maxmind&#39;</span><span class="hl-1">;</span><br/><br/><span class="hl-1">(</span><span class="hl-0">async</span><span class="hl-1"> () </span><span class="hl-0">=&gt;</span><span class="hl-1"> {</span><br/><span class="hl-1">  </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">reader</span><span class="hl-1"> = </span><span class="hl-7">await</span><span class="hl-1"> </span><span class="hl-6">geolite2</span><span class="hl-1">.</span><span class="hl-3">open</span><span class="hl-1">(</span><br/><span class="hl-1">    </span><span class="hl-6">GeoIpDbName</span><span class="hl-1">.</span><span class="hl-6">Country</span><span class="hl-1">, </span><span class="hl-5">// Use the enum instead of a string!</span><br/><span class="hl-1">    (</span><span class="hl-6">path</span><span class="hl-1">) </span><span class="hl-0">=&gt;</span><span class="hl-1"> </span><span class="hl-6">maxmind</span><span class="hl-1">.</span><span class="hl-3">open</span><span class="hl-1">&lt;</span><span class="hl-8">CountryResponse</span><span class="hl-1">&gt;(</span><span class="hl-6">path</span><span class="hl-1">)</span><br/><span class="hl-1">  )</span><br/><br/><span class="hl-1">  </span><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">lookup</span><span class="hl-1"> = </span><span class="hl-6">reader</span><span class="hl-1">.</span><span class="hl-3">get</span><span class="hl-1">(</span><span class="hl-4">&#39;185.194.81.29&#39;</span><span class="hl-1">)</span><br/><br/><span class="hl-1">  </span><span class="hl-6">console</span><span class="hl-1">.</span><span class="hl-3">log</span><span class="hl-1">(</span><span class="hl-6">lookup</span><span class="hl-1">.</span><span class="hl-6">country</span><span class="hl-1">.</span><span class="hl-6">iso_code</span><span class="hl-1">) </span><span class="hl-5">// FR 🥖🇫🇷</span><br/><br/><span class="hl-1">  </span><span class="hl-6">reader</span><span class="hl-1">.</span><span class="hl-3">close</span><span class="hl-1">()</span><br/><span class="hl-1">})();</span>
</code></pre>

<a href="#preloading-databases" id="preloading-databases" style="color: inherit; text-decoration: none;">
  <h3>Preloading databases</h3>
</a>
<p>You can add this to your <code>package.json</code> to preload the databases after running <code>npm install</code>, instead of downloading them the first time <code>open</code> is called:</p>
<pre><code class="language-json"><span class="hl-1">{</span><br/><span class="hl-1">  </span><span class="hl-9">&quot;scripts&quot;</span><span class="hl-1">: {</span><br/><span class="hl-1">    </span><span class="hl-9">&quot;preload&quot;</span><span class="hl-1">: </span><span class="hl-4">&quot;node -e </span><span class="hl-10">\&quot;</span><span class="hl-4">import(&#39;geolite2-redist&#39;).then(geolite =&gt; geolite.downloadDbs())</span><span class="hl-10">\&quot;</span><span class="hl-4">&quot;</span><br/><span class="hl-1">  }</span><br/><span class="hl-1">}</span>
</code></pre>

<a href="#api" id="api" style="color: inherit; text-decoration: none;">
  <h2>API</h2>
</a>
<p>You can find a more detailed documentation <a href="https://gitsquared.github.io/node-geolite2-redist/modules.html">on the Typedoc-generated website</a>.</p>

<a href="#legal-warning" id="legal-warning" style="color: inherit; text-decoration: none;">
  <h2>Legal Warning</h2>
</a>
<p>Privacy regulations (CCPA in California, GDPR in Europe) that implement the right-to-forget have affected MaxMind&#39;s EULA &amp; licenses.
In a nutshell, you should always make sure your GeoIP databases are up to date, which this library conveniently does for you ;)</p>
<p>That said, please carefully read the LICENSE and EULA files. The databases are provided under certain restrictions and obligations, most notably:</p>
<ul>
<li>You cannot prevent the library from updating the databases.</li>
<li>You cannot use the GeoLite2 data:<ul>
<li>for <a href="https://www.ftc.gov/enforcement/statutes/fair-credit-reporting-act">FCRA</a> purposes in the USA,</li>
<li>to identify specific households or individuals, worldwide.</li>
</ul>
</li>
</ul>
<p>If you plan on using <code>node-geolite2</code> behind a firewall, you need to whitelist the <a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses">GitHub IP range</a> so that the package can reach the databases mirror.</p>

<a href="#compatibility" id="compatibility" style="color: inherit; text-decoration: none;">
  <h2>Compatibility</h2>
</a>
<p>We follow the OpenJS Foundation&#39;s <a href="https://nodejs.org/en/about/releases/">deprecation schedule</a> and support all maintained Node versions.</p>

<a href="#alternatives" id="alternatives" style="color: inherit; text-decoration: none;">
  <h2>Alternatives</h2>
</a>
<p>If you do have a MaxMind license key (which you can get by signing up <a href="https://www.maxmind.com/en/geolite2/signup">here</a>), you might prefer using <a href="https://github.com/runk/node-geolite2"><code>node-geolite2</code></a>, which this repository is originally a fork of.</p>

<a href="#license" id="license" style="color: inherit; text-decoration: none;">
  <h2>License</h2>
</a>
<p>The databases themselves are provided by MaxMind under <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a></p>
<p>For the library, see <a href="https://github.com/GitSquared/node-geolite2-redist/blob/master/LICENSE">LICENSE</a>.</p>
<hr>
<p><strong>This software package includes GeoLite2 data created by MaxMind, available from <a href="https://www.maxmind.com">https://www.maxmind.com</a>.</strong></p>
</div></div>
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">
<div class="tsd-navigation settings">
<details class="tsd-index-accordion"><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Settings</h3></summary>
<div class="tsd-accordion-details">
<div class="tsd-filter-visibility">
<h4 class="uppercase">Member Visibility</h4><form>
<ul id="tsd-filter-options">
<li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></form></div>
<div class="tsd-theme-toggle">
<h4 class="uppercase">Theme</h4><select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div>
<nav class="tsd-navigation primary">
<details class="tsd-index-accordion" open><summary class="tsd-accordion-summary">
<h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><path d="M4.93896 8.531L12 15.591L19.061 8.531L16.939 6.409L12 11.349L7.06098 6.409L4.93896 8.531Z" fill="var(--color-text)"></path></svg> Modules</h3></summary>
<div class="tsd-accordion-details">
<ul>
<li class="current selected"><a href="modules.html">geolite2-<wbr/>redist -<wbr/> v3.0.3</a>
<ul></ul></li></ul></div></details></nav>
<nav class="tsd-navigation secondary menu-sticky">
<ul>
<li class="tsd-kind-enum"><a href="enums/GeoIpDbName.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-enum)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-8-path"></rect><path d="M9.45 16V7.24H14.49V8.224H10.518V10.936H14.07V11.908H10.518V15.016H14.49V16H9.45Z" fill="var(--color-text)" id="icon-8-text"></path></svg>Geo<wbr/>Ip<wbr/>Db<wbr/>Name</a></li>
<li class="tsd-kind-type-alias"><a href="types/WrappedReader.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-4194304-path"></rect><path d="M11.31 16V8.224H8.91V7.24H14.79V8.224H12.39V16H11.31Z" fill="var(--color-text)" id="icon-4194304-text"></path></svg>Wrapped<wbr/>Reader</a></li>
<li class="tsd-kind-function"><a href="functions/downloadDbs.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><rect fill="var(--color-icon-background)" stroke="var(--color-ts-function)" stroke-width="1.5" x="1" y="1" width="22" height="22" rx="6" id="icon-64-path"></rect><path d="M9.39 16V7.24H14.55V8.224H10.446V11.128H14.238V12.112H10.47V16H9.39Z" fill="var(--color-text)" id="icon-64-text"></path></svg>download<wbr/>Dbs</a></li>
<li class="tsd-kind-function"><a href="functions/open.html" class="tsd-index-link"><svg class="tsd-kind-icon" width="24" height="24" viewBox="0 0 24 24"><use href="#icon-64-path"></use><use href="#icon-64-text"></use></svg>open</a></li></ul></nav></div></div>
<div class="container tsd-generator">
<p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div>
<div class="overlay"></div><script src="assets/main.js"></script></body></html>